#include "Command.hpp"
#include "TcpServer.hpp"

using namespace std;

string defaulthandler(const string& word,InetAddr& addr)
{
    LOG(LogLevel::DEBUG)<<"回调到了defaulthandler";
    string s="haha,";
    s+=word;
    return s;
}

void Usage(string proc)
{
    cerr<<"Usage:"<<proc<<"port"<<endl;
}

int main(int argc,char* argv[])
{
    if(argc!=2)
    {
        Usage(argv[0]);
        return 0;
    }
    uint16_t port = stoi(argv[1]);

    Enable_Console_Log_Strategy();
    Command cmd;
    unique_ptr<TcpServer>tsvr=make_unique<TcpServer>(port,bind(&Command::Execute,&cmd,placeholders::_1,placeholders::_2));
    //创建一个 TcpServer 对象，并把 Command::Execute 作为消息处理回调函数传入
    tsvr->Init();
    tsvr->Run();
    return 0;
}
